快速选择排序
https://leetcode.cn/problems/zui-xiao-de-kge-shu-lcof/

class Solution {
public:
    void qsort(vector<int>& nums,int l,int r,int k)
    {
        if(l>=r)
            return ;
        
        int key=nums[rand()%(r-l+1)+l];

        int i=l,left=l-1,right=r+1;
        while(i<right)
        {
            if(nums[i]<key)
                swap(nums[++left],nums[i++]);
            else if(nums[i]==key)
                ++i;
            else
                swap(nums[--right],nums[i]);
        }

        if(k<left-l+1)
            return qsort(nums,l,left,k);
        else if(k<=right-l)
            return;
        else
            return qsort(nums,right,r,k-(right-l));

    }

    vector<int> inventoryManagement(vector<int>& nums, int k) {
        srand(time(nullptr));
        qsort(nums,0,nums.size()-1,k);
        return {nums.begin(),nums.begin()+k};
    }
};